<?php
/* @var $this CourseController */
/* @var $id id*/
$this->main_menu = MenuHelper::getArrayForMainMenu(false, true, false);
?>

<?php
$this->widget('bootstrap.widgets.TbTabs', array(
	'type'=>'tabs', // 'tabs' or 'pills'
	'tabs'=>array(
		array('label'=>'Übersicht', 'url'=>$this->createUrl('course/admin'), 'active'=>false),
		array('label'=>'NEU', 'url'=>$this->createUrl('course/create'), 'active'=>false),
		array('label'=>'NEU aus Vorlage', 'url'=>$this->createUrl('course/chooseTemplate'), 'active'=>false),
//                array('label'=>'|', 'itemOptions'=>array('class'=>'disabled'), 'url'=>$this->createUrl('course/viewSubModules', array('id'=>$id))),
                array('label'=>'Stammdaten', 'url'=>$this->createUrl('course/update', array('id'=>$id)), 'active'=>false),
                array('label'=>'Kombi', 'url'=>$this->createUrl('course/viewSubModules', array('id'=>$id)), 'active'=>false),
                array('label'=>'Trainer', 'url'=>$this->createUrl('course/trainer', array('id'=>$id)), 'active'=>true),
                array('label'=>'Teilnehmer', 'url'=>$this->createUrl('course/user', array('id'=>$id)), 'active'=>false),
//                array('label'=>'|', 'itemOptions'=>array('class'=>'disabled'), 'url'=>$this->createUrl('course/viewSubModules', array('id'=>$id))),

	),
));
?>

<?php

    $model = Trainer::model();
    $lead_trainer = $this->getLeadTrainerDropdownArrayForCourse($id);
    
    $course = Course::model()->findByPk($id);
    $trainers = new CArrayDataProvider($course->trainers, array(
       'keyField' => 'trainer_id', 
    ));
?>

<?php /** @var BootActiveForm $form */
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id'=>'horizontalForm',
	'type'=>'horizontal',
)); ?>
     
<fieldset>

	<?php
	echo $form->dropDownListRow($model, 'trainer_id', $lead_trainer,
            array(
                    'ajax' => array(
                            'type'=>'POST',
                            'url'=>CController::createUrl('course/addLeadTrainer', array('course_id'=>$id)),
                    )
            )
        );
	?>          


</fieldset>

<?php $this->endWidget(); ?>

<h3><br>Weitere Trainer:</h3>

<?php

    $this->widget('bootstrap.widgets.TbExtendedGridView', array(
//    'filter'=>$model,
    'fixedHeader' => false,
    'headerOffset' => 40, 
    'type'=>'striped bordered',
    'dataProvider' => $trainers,
        'template' => '{items}{pager}', // 2nd way
//    'template' => "{items}",
	'columns'=>array(
//            'first_name',
            array(
                'name'=>'Vorname',
                'value'=>'$data->first_name',
            ),
            array(
                'name'=>'Nachname',
                'value'=>'$data->last_name',
            ),
//            'last_name',
            array (
                'class'=>'CButtonColumn',
                'template'=>'{entfernen}',
                'buttons' => array(
                  'entfernen' => array(
                    'url'=>'Yii::app()->createUrl("course/deleteTrainerFromCourse", array("trainer_id"=>$data->trainer_id, "course_id"=>' . $id . '))',  
                  ),
                ),
            ),
	),
    ));
?>

<?php
$this->widget('bootstrap.widgets.TbButton', array(
    'label' => 'Trainer hinzufügen',
    'size' => 'medium',
    'url' => $this->createUrl('course/addTrainerToCourse', array('trainer_id'=>null, 'course_id' => $id)),
));
?>
